<template>
    <el-button style="width: 100%" @click="openDialog()">添加裸眼段</el-button>
    <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="top" label="裸眼井顶部深度（ m ）" width="170" />
        <el-table-column prop="bottom" label="裸眼井底部深度（ m ）" width="170" />
        <el-table-column prop="weight" label="单位质量（ kg/m ）" width="170" />
        <el-table-column fixed="right" label="操作" width="120">
            <template #default="scope">
                <el-button link type="primary" @click="openDialog(scope.row)">编辑</el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-dialog v-model="dialogFormVisible" :title="title" width="340px">
        <el-form :model="formData" label-width="120px">
            <el-form-item label="顶 部 （ m ）">
                <el-input-number v-model="formData.top" class="mx-4" :min="0" controls-position="right" />
            </el-form-item>
            <el-form-item label="底 部（ m ）">
                <el-input-number v-model="formData.bottom" class="mx-4" :min="0" controls-position="right" />
            </el-form-item>
            <el-form-item label="重 量（ kg/m ）">
                <el-input-number v-model="formData.weight" class="mx-4" :min="0" controls-position="right" />
            </el-form-item>
            <el-form-item>
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取消</el-button>
                <el-button type="primary" @click="add()">
                    确定
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script setup>
import { ref } from 'vue';

// import { initOpenHole } from "@/api/openHole"
// import openHoleStore from '@/store/modules/openHoleDraw'
import d3DrawStore from '@/store/modules/d3Draw'
const d3Draw = d3DrawStore();
// const openHoleDraw = openHoleStore();
const dialogFormVisible = ref(false)
const title = ref()
const tableData = ref([{
    top: 0,
    bottom: 1736,
    weight: 0
}])
const formData = ref({
    top: 0,
    bottom: 1736,
    weight: 0
})
const add = () => {
    const $ = d3Draw.$;
    const d3Canvas = d3Draw.d3Canvas;
    if (title.value === '添加裸眼段') {

    } else if (title.value === '修改裸眼段') {

    }

}
function openDialog(item) {
    if (item === undefined) {
        title.value = '添加裸眼段'
    } else {
        title.value = '修改裸眼段'
        formData.value = item
    }
    dialogFormVisible.value = true
}

</script>